package com.ruoyi.stage.service.impl;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.stage.domain.StuStage;
import com.ruoyi.stage.mapper.StuStageMapper;
import com.ruoyi.stage.service.IStuStageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class StuStageImpl implements IStuStageService {
    @Resource
    private StuStageMapper stuStageMapper;

    @Override
    public List<StuStage> selectStage(StuStage stuStage) {
        return stuStageMapper.selectStage(stuStage);
    }

    @Override
    public StuStage selectStageById(Long stageId) {
        return stuStageMapper.selectStageById(stageId);
    }

    @Override
    public int insertStuStage(StuStage stuStage) {
        return  stuStageMapper.insertStuStage(stuStage);
    }

    @Override
    public String checkStageNameUnique(StuStage stuStage) {
        Long StageId = StringUtils.isNull(stuStage.getStageId()) ? -1L : stuStage.getStageId();
        StuStage info = stuStageMapper.checkStageNameUnique(stuStage.getStageName());
        if (StringUtils.isNotNull(info) && info.getStageId().longValue() != StageId.longValue())
        {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }

    @Override
    public int updateStuStage(StuStage stuStage) {
        return stuStageMapper.updateStuStage(stuStage);
    }

    @Override
    public int deleteStuStageByIds(Long[] stageIds) {
        return stuStageMapper.deleteStuStageByIds(stageIds);
    }

    @Override
    public List<StuStage> selectAllStages() {
        return stuStageMapper.selectAllStages();
    }

    @Override
    public List<Long> selectStuStagesListByStoreId(Long storeId) {
        return stuStageMapper.selectStuStagesListByStoreId(storeId);
    }
}
